const mongoose = require('mongoose')

// 连接DB
const DB_URL = 'mongodb://localhost:27017/test'
mongoose.connect(DB_URL);
mongoose.connection.on('connected', function() {
	console.log('mongo connect..success2 ')
})
const mouels = {
	user: {
		'user': {
			type: String,
			require: true
		},
		'pwd': {
			type: String,
			require: true
		},
		'type': {
			type: String,
			require: true
		},
		'avatar': {
			type: String
		},
		'desc': {
			type: String
		},
		title: {
			type: String
		},
		'company': {
			type: String
		},
		'money': {
			type: String
		}
	},
	chat: {}
}
for (let m in mouels) {
	mongoose.model(m, new mongoose.Schema(mouels[m]))
}
module.exports = {
	getModel: function(name) {
		return mongoose.model(name)
	}
}
